package com.frxuexi.myroom.viewmodel

import com.frxuexi.lib_base.BaseViewModel
import com.frxuexi.lib_base.RequestType
import com.frxuexi.lib_http.HttpType
import com.frxuexi.myroom.intent.UserIntent
import com.frxuexi.myroom.repository.UserRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class UserViewModel @Inject constructor(private val userRepository: UserRepository):BaseViewModel<UserIntent>(){
    override fun handleIntent(it: UserIntent) {
        when(it){
            is UserIntent.register->
                roomRequest(userRepository.register(it.user))
            is UserIntent.login->
                roomRequest(userRepository.login(it.uname,it.upass,it.role))
            is UserIntent.updataLogin->
                roomRequest(userRepository.updataLogin(it.user),RequestType.UPDATALOGIN)
            is UserIntent.getLogin->
                roomRequest(userRepository.getLogin())

            else -> {}
        }
    }
}